<template>
    <div>{{name}}</div>
</template>

<script>
export default {
    data(){
        return {
           name: ''
        }
    },
    mounted(){
        this.openDialog()
    },
    methods:{ 
        openDialog(){
        var filePath = "http://chaoyang.nxers.com/attachment/files/2020/09/04/7e157e1dgy1fxfdxl84glj20vn0hsgnd_1009.jpg";
        //获取最后一个.的位置
        var index= filePath.lastIndexOf(".");
        //获取后缀
        var ext = filePath.substr(index+1);
        //判断是否是图片
        if(ext=='docx'||ext=='doc'){
          this.name="one这是docx/doc"
        }else if(ext=='ppt'||ext=='pptx'){
          this.name="one这是ppttx"
        }else if(ext=='exe'){
          this.name="one这是exe"
        }else if(ext=='pdf'){
          this.name="one这是PDF"
        }else if(ext=='zip'){
          this.name="one这是压缩包"
        }else if(ext=='pdf'){
          this.name="one这是PDF"
        }else if(ext=='gif'){
          this.name="one这是动态图"
        }else if(ext=='jpg'||ext=='png'||ext=='jpeg'){
          this.name="one这是一张图片"
        }
        
      }
      
    },
}
</script>